{% extends "base.html" %}
{% load i18n %}
{% load comments %}
{% load account socialaccount %}
{% block title %}首页{% endblock %}

{% block head %}
  {% include 'banner.html' %}
{% endblock %}

{% block content %}

    <script>
    function like_cz(id,action){

            $.ajax({
                    url:"/like",
                    type:"get",
                    async: false,
                    dataType:"json",
                    data:{
                        'id':id,
                        'action':action,
                        csrfmiddlewaretoken:'{{ csrf_token }}',
                        
                    },
                    success:function(result){
                    console.log(result);
                     if (result['message']=="dzcg")
                     {
                        $('#like_text'+id).text("已点赞("+result['like_number']+")")
                        $('#like_text'+id).attr("style","color:#DC143C")
                        $('#like_text'+id).attr("onclick","flase");
                     }
                     else if (result['message']=="sccg")
                     {
                      $('#sc_text'+id).text("已收藏")
                     }

                    }
                })
        }
    </script> 

  {% for article in wz %}
      <!-- 文章内容 -->
  <article class="excerpt excerpt-1">
     <a class="focus" href="article.html" title="">
      <!--<img class="thumb" data-original="{{m.pic}}" src="{{m.pic}}" alt="">-->
    </a>
          <header><a class="cat" href="program">{{article.wzfenlei}}<i></i></a>
            <h2><a href="/read/?id={{ article.id }}">{% autoescape off %}{{ article.title }}{% endautoescape %}</a></h2>
          </header>

          <p class="meta">
              <span  class="glyphicon glyphicon-time"></span> {{article.created_time}}
              <span  class="glyphicon glyphicon-user"></span> 作者:{{article.user}}
              <span  class="glyphicon glyphicon-eye-open"></span>浏览量({{article.views}})

              {% get_comment_count for article as comment_count %}
              <a class="comment" href="/read/?id={{ article.id }}">
               <span class="glyphicon glyphicon-comment"></span> 评论({{comment_count}})</a>
              <span id="like" class="glyphicon glyphicon-thumbs-up" aria-hidden="true" ></span>
              <a id="like_text{{article.id}}" onclick="like_cz({{article.id}},'like')">点赞({{article.like__count}})</a>
<!--              <span id="like_text{{article.id}}" onclick="like_cz({{article.id}},'like')">点赞({{article.like__count}})</span>-->

              <span id="sc" class="glyphicon glyphicon-star-empty" aria-hidden="true" ></span>
              <a id="sc_text{{article.id}}" onclick="like_cz({{article.id}},'sc')">点我收藏</a>
<!--              <span id="sc_text{{article.id}}" onclick="like_cz({{article.id}},'sc')">点我收藏</span>-->


          </p>
      <!-- 摘要 --> <p class="note"> {% autoescape off %}{{ article.wz|slice:'400'}}{% endautoescape %}... </p>
  </article>


    {% endfor %}
{%  endblock %}

{% block right %}
{% include 'right.html' %}
{%  endblock %}


